package cc.admin.modules.graduate.service.impl;

import cc.admin.modules.graduate.entity.ChoiceErrorQuestionsMulti;
import cc.admin.modules.graduate.mapper.ChoiceErrorQuestionsMultiMapper;
import cc.admin.modules.graduate.service.IChoiceErrorQuestionsMultiService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Description: 多选题错题
 * @Author: cc-admin
 * @Date:   2025-02-26
 * @Version: V1.0.0
 */
@Service
public class ChoiceErrorQuestionsMultiServiceImpl extends ServiceImpl<ChoiceErrorQuestionsMultiMapper, ChoiceErrorQuestionsMulti> implements IChoiceErrorQuestionsMultiService {

    @Autowired
    private ChoiceErrorQuestionsMultiMapper choiceErrorQuestionsMultiMapper;

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public  List<String> getNoVideoList(String tab) {

        String sql = "SELECT question_id,COUNT(question_id) as question_count FROM choice_error_questions_multi WHERE subject_id = ? and question_id is not NULL and (viedo_url is null or viedo_url = '') GROUP BY question_id;";
        List<Map<String, Object>> queryForMap = jdbcTemplate.queryForList(sql, tab);
        List<String> questionIds = new ArrayList<>();
        for (Map<String, Object> map : queryForMap) {
            Object questionIdObj = map.get("question_id");
            if (questionIdObj != null) {
                questionIds.add(questionIdObj.toString());
            }
        }
        return questionIds;

    }
}
